﻿@model LoginViewModel
@{
	Layout = null;
}
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>@Resources.Login@ConstValues.strDash@Resources.HuiTongCIS</title>
	@Scripts.Render("~/bundles/jquery")
	<script type="text/javascript" src="~/Scripts/jquery.cookie.js"></script>
	<link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.5/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.5/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="~/Content/Login.css" />
	<link rel="stylesheet" type="text/css" href="~/Content/Style.css" />
	<link rel="stylesheet" type="text/css" href="~/Content/Site.css" />
	<script type="text/javascript" charset="utf-8" src="~/Scripts/layer/layer.js"></script>
	<script type="text/javascript" charset="utf-8" src="~/Scripts/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>
	@*<script type="text/javascript" charset="utf-8" src="~/Scripts/homepage/jquery.js"></script>*@
	<script type="text/javascript" charset="utf-8" src="~/Scripts/homepage/lrtk.js"></script>
	<script>
		$(function () {
			var language = "@ViewBag.Language";
			@if (Request.Cookies["_culture"] == null) {
				<text>
				$("#hidCulture").val(language);
				$("#frmCulture").submit();
				</text>
			} else {
				<text>
				if (language != "@Request.Cookies["_culture"].Value") {
					$("#hidCulture").val(language);
					$("#frmCulture").submit();
				}
				</text>
			}

			if (language == "@ConstValues.Language.Cn") {
				$("#cultureCn").css("background-color", "#c30d23");
				$("#cultureEn").css("background-color", "#7c7c7c");
				$("#hidCulture").val(language);
				$("#mlogo").append('<img id="logo" src="../Images/homeImg/logo.png" />');
				$("#loginLogo").append('<img src="../Images/homeImg/login_logo.png" align="absmiddle">')

				$("#cultureEn").hover(function () {
					$(this).css("color", "#c30d23");
					$(this).css("background-color", "#fff");
				}, function () {
					$(this).css("color", "#fff");
					$(this).css("background-color", "#7c7c7c");
				})
			} else {
				$("#cultureCn").css("background-color", "#7c7c7c");
				$("#cultureCn").css("borderRight", "0px");
				$("#cultureEn").css("background-color", "#c30d23");
				$("#mlogo").append('<img id="logo" src="../Images/homeImg/login_enlogo2.png" />')
				$("#loginLogo").append('<img src="../Images/homeImg/login_enlogo.png" align="absmiddle">')
				$("#hidCulture").val(language);

				$("#cultureCn").hover(function () {
					$(this).css("color", "#c30d23");
					$(this).css("background-color", "#fff");
				}, function () {
					$(this).css("color", "#fff");
					$(this).css("background-color", "#7c7c7c");
				})
			}

			@if (!string.IsNullOrEmpty(Model.AccountName) && !string.IsNullOrEmpty(Model.Password)) {
				<text>
				$("#txtAccountName").val("@Model.AccountName");
				$("#txtPassword").val("@Model.Password");
				</text>
			}

			@if (Model.Msg == Resources.MsgUserActivate) {
				<text>
				showSuccess("@Model.Msg", true);
				</text>
			} else if (!string.IsNullOrEmpty(Model.Msg)) {
				<text>
				//showCheckError("@Model.Msg");
				showError("@Model.Msg");
				</text>
			}

			var url = "@Url.Action(nameof(AccountController.GetValidateCode), nameof(AccountController).GetControllerName())";
			if ("@Model.ValidateCode" != "") {
				url += "?validateCode=@Model.ValidateCode";
				$("#hidValidateCode").val("@Model.ValidateCode");
			} else {
				$("#hidValidateCode").val("");
			}
			document.getElementById("validateCodeImg").src = url;
		});

		function checkLogin() {
			var noUsername = document.getElementById("noUsername");
			var noPassword = document.getElementById("noPassword");
			var noValidateCode = document.getElementById("noValidateCode");
			var checkValidateCode = document.getElementById("checkValidateCode");
			noUsername.style.display = "none";
			noPassword.style.display = "none";
			noValidateCode.style.display = "none";
			checkValidateCode.style.display = "none";

			if ($("#txtAccountName").val() == "" || $("#txtAccountName").val() == "@Resources.MsgEnterUserName") {
				noUsername.style.display = "inline-block";
				return false;
			}
			if ($("#txtPassword").val() == "") {
				noPassword.style.display = "inline-block";
				return false;
			}
			if ($("#txtValidateCode").val() == "" || $("#txtValidateCode").val() == "@Resources.MsgEnterValidateCode") {
				noValidateCode.style.display = "inline-block";
				return false;
			}
			if ($("#txtValidateCode").val() != $("#hidValidateCode").val()) {
				checkValidateCode.style.display = "inline-block";
				return false;
			}

			if ($("#chkRememberMe").prop("checked")) {
				$("#hidRememberMe").val(true);
				$.cookie("username", $("#txtAccountName").val(), { expires: 7 });
				$.cookie("password", $("#txtPassword").val(), { expires: 7 });
			} else {
				$("#hidRememberMe").val(false);
				$.cookie("username", "", { expires: -1 });
				$.cookie("password", "", { expires: -1 });
			}

			$("#loginButton").attr("disabled", true);
			$("#loginButton").css("opacity", 0.4);
			$("#loginButton").html("@Resources.Logining");

			$.post("@Url.Action(nameof(AccountController.CheckLogin),
				nameof(AccountController).GetControllerName())" + "?returnUrl=@ViewBag.ReturnUrl",
				$("#frmLogin").serialize(),
				function (data, textStatus, jqXHR) {
					if (data.result == "@ConstValues.AjaxFailResult") {
						if (data.message.indexOf("@ConstValues.MailAddress") > 1) {
							$.messager.alert("@Resources.Tip", data.message);
						} else {
							showCheckError(data.message);
						}
						//showError(data.message);
						$("#loginButton").attr("disabled", false);
						$("#loginButton").css("opacity", 1);
						$("#loginButton").html("@Resources.LoginBlank");
					} else {
						window.location.href = data.message;
					}
				}
			);
		}

		function showCheckError(errorText) {
			if (errorText) {
				$("#loginError").html(errorText);
			}

			$("#loginError").fadeIn("normal", function () {
				setTimeout(function () {
					$("#loginError").fadeOut("normal", function () {
						$("#loginError").html("");
					});
				}, 10000);
			});
		}

		function sendMail() {
			var isValid = $("#frmMail").form("validate");
			if (isValid) {
				var loading = layer.load(0, {
					shade: [0.4, "#fff"]
				});
				$('#frmMail').submit();
				layer.close(loading);
			}
		}

		function showError(errorText) {
			var lt = new RegExp("&lt;", "g"); //定义正则表达式 add by zhaoyueqi
			var gt = new RegExp("&gt;", "g"); //定义正则表达式
			errorText = errorText.replace(lt, "<");
			errorText = errorText.replace(gt, ">");

			$("#fixedErrorMessageContent").html(errorText);
			$(".fixedErrorMessage").slideDown("normal", function () {
				setTimeout(function () {
					$(".fixedErrorMessage").slideUp("normal", function () {
						$("#fixedErrorMessageContent").html("");
					});
				}, 5000);
			});
		};

		function showSuccess(successText, autoClose) {
			$("#fixedSuccessMessageContent").html(successText);
			$(".fixedSuccessMessage").slideDown("normal", function () {
				if (autoClose) {
					setTimeout(function () {
						$(".fixedSuccessMessage").slideUp("normal", function () {
							$("#fixedSuccessMessageContent").html("");
						});
					}, 5000);
				}
			});
		};
	</script>
</head>
<body id="login">
	<div class="mar" style="position:relative;z-index:999">
		<div class="index">
			<!-- header start -->
			<div class="header02">
				<div class="t">
					<div class="fl"><img src="~/Images/homeImg/icon_01.png" align="absmiddle" width="16" />&nbsp;&nbsp;@Resources.Welcome@Resources.Vister&nbsp;&nbsp;</div>
					<div class="fl">
						@using (Html.BeginForm(nameof(UtilityController.SetCulture), nameof(UtilityController).GetControllerName(), FormMethod.Post, new { id = "frmCulture" }))
						{
							<a href="javascript:$('#hidCulture').val('@ConstValues.Language.Cn');$('#frmCulture').submit();" id="cultureCn" class="cn">@Resources.Chinese</a>
							<a href="javascript:$('#hidCulture').val('@ConstValues.Language.En');$('#frmCulture').submit();" id="cultureEn" class="en">@Resources.English</a>
							<input type="hidden" id="hidCulture" name="culture" />
						}
					</div>
				</div>
				<div class="clear"></div>
			</div>
			<!-- header end -->
			<!-- container start -->
			<div class="container">
				<div class="fl" id="mlogo"></div>
				<div class="fr mainmenu">
					<ul>
						<li><a href="@Url.Action(nameof(HomeController.Help),nameof(HomeController).GetControllerName())"><h3>@Resources.Help</h3></a></li>
						<li><a href="@Url.Action(nameof(HomeController.AboutUs),nameof(HomeController).GetControllerName())"><h3>@Resources.AboutUs</h3></a></li>
						<li><a href="@Url.Action(nameof(MeetingListLogoutController.Index),nameof(MeetingListLogoutController).GetControllerName())"><h3>@Resources.MeetingList</h3></a></li>
						<li><a href="@Url.Action(nameof(HomeController.MainIndex),nameof(HomeController).GetControllerName())"><h3>@Resources.HomePage</h3></a></li>
					</ul>
				</div>
				<div class="clear"></div>
			</div>
			<!-- container end -->
		</div>
		<div style="border-top: 2px #d9d9d9 solid; height:10px;"></div>
		<div class="index">
			<!-- login start -->
			<div class="login">
				<div class="con">
					<!-- slide start -->
					<div class="slide-login" id="touchMain" style="width:700px;height:450px; display:inline-block;">
						<a class="prev" style="top:200px;" href="javascript:;" stat="prev1001"><img src="../Images/homeImg/l-btn.png" /></a>
						<div class="slide-box" id="slideContent1" style="height:100%">
							@if (Model.SliderList.Count > 0) {
								for (int index = 0; index < Model.SliderList.Count(); index++) {
									if (index <= 4) {
										if (!string.IsNullOrEmpty(Model.SliderList[index].link)) {										
											<div class="slide" style="display:none;height:450px;padding-top:0px;position:relative;position:absolute;z-index:8;">
												<a stat="sslink-@index" href="@Model.SliderList[index].link" target="_blank">
													<img src="@Url.Action(nameof(AccountController.LoginNewsImg), nameof(AccountController).GetControllerName())?id=@Model.SliderList[index].id" style="height:450px;width:100%">
												</a>
											</div>
										} else {
											<div class="slide" style="display:none;height:450px;padding-top:0px;position:relative;position:absolute;z-index:8;">
												<a stat="sslink-@index">
													<img src="@Url.Action(nameof(AccountController.LoginNewsImg), nameof(AccountController).GetControllerName())?id=@Model.SliderList[index].id" style="height:450px;width:100%">
												</a>
											</div>
										}
									}
								}
							} else {
								<div class="slide" id="bgstyled">
									<a stat="sslink-1" href="#">
										<div class="obj-a"></div>
										<div class="obj-f">
											<img src="~/Images/ConferenceNoPic.png" style="height:450px;width:100%">
										</div>
									</a>
								</div>
							}
						</div>
						<a class="next" style="top:200px;" href="javascript:;" stat="next1002"><img src="../Images/homeImg/r-btn.png" /></a>
						<div class="item" style="top:390px">
							@for (int index = 0; index < Model.SliderList.Count(); index++) {
								if (index == 0) {
									<a class="cur" stat="item@(index + 1)" href="javascript:;"></a>
								} else if (index <= 4) {
									<a href="javascript:;" stat="item@(index + 1)"></a>
								}
							}
						</div>
					</div>
					<!-- slide end -->
					<div class="box">
						<form id="frmLogin" method="post">
							@Html.AntiForgeryToken()
							<div class="logo" id="loginLogo"></div>
							<div class="clear"></div>
							<div class="sr">
								<div class="c">
									<span><img src="~/Images/homeImg/login_icon1.png" /></span>
									<input type="text" id="txtAccountName" name="AccountName"
										onblur="if(this.value == '')this.value='@Resources.MsgEnterUserName';"
										onclick="if (this.value == '@Resources.MsgEnterUserName') this.value = '';" value="@Resources.MsgEnterUserName" />
								</div>
							</div>
							<div id="noUsername" style="display:none; vertical-align: central; position:relative;margin-bottom:15px">
								<img src="~/Content/jquery-easyui-1.4.5/themes/icons/no.png" alt="">
								<span style="color:red;position:relative;top:-3px;">@Resources.MsgEnterUserName</span>
							</div>
							<div class="sr">
								<div class="c">
									<span><img src="~/Images/homeImg/login_icon2.png" /></span>
									<input type="password" id="txtPassword" name="Password" />
								</div>
							</div>
							<div id="noPassword" style="display:none; vertical-align: central; position:relative;margin-bottom:15px">
								<img src="~/Content/jquery-easyui-1.4.5/themes/icons/no.png" alt="">
								<span style="color:red;position:relative;top:-3px;">@Resources.MsgEnterPassword</span>
							</div>
							<div class="sr">
								<div class="c">
									<span><img src="~/Images/homeImg/login_icon3.png" /></span>
									<input type="text" id="txtValidateCode" name="ValidateCode" style="width:200px;"
										onblur="if (this.value == '') this.value = '@Resources.MsgEnterValidateCode';"
										onclick="if (this.value == '@Resources.MsgEnterValidateCode') this.value = '';" value="@Resources.MsgEnterValidateCode" />
									<input type="hidden" id="hidValidateCode" name="InitValidateCode">
									<a><img id="validateCodeImg" width="120" height="35" style="float:right" onclick="this.src = '@Url.Action(nameof(AccountController.GetValidateCode), nameof(AccountController).GetControllerName())?'+Math.random()" /></a>
								</div>
							</div>
							<div id="noValidateCode" style="display:none; vertical-align: central; position:relative;">
								<img src="~/Content/jquery-easyui-1.4.5/themes/icons/no.png" alt="">
								<span style="color:red;position:relative;top:-3px;">@Resources.MsgEnterValidateCode</span>
							</div>
							<div id="checkValidateCode" style="display:none; vertical-align: central; position:relative;">
								<img src="~/Content/jquery-easyui-1.4.5/themes/icons/no.png" alt="">
								<span style="color:red;position:relative;top:-3px;">@Resources.MsgCheckCodeError</span>
							</div>
							<div class="login_btn"><a class="button" id="loginButton" onclick="checkLogin();">@Resources.LoginBlank</a></div>
							<div class="login_info" style="padding-top:5px">
								<div class="fl">
									<input type="checkbox" id="chkRememberMe" class="index-checkbox" style="float:left" />
									<input type="hidden" id="hidRememberMe" name="RememberMe">
									<span style="float:left; display:inline-block;">@Resources.RememberMe</span>
								</div>
								<div class="fr">
									<a href="javascript:void(0);" onclick="$('#mailWindow').window('open');">@Resources.GetPassword</a>&nbsp;&nbsp;&nbsp;&nbsp;
									<a href="javascript:void(0);" class="reg" onclick="$(window.location).attr('href', '@Url.Action(nameof(RegisterController.Index), nameof(RegisterController).GetControllerName())');">@Resources.Register</a>
								</div>
							</div>
							<div class="clear"></div>
							<div id="loginError" style="display:inline-block; text-align: left; color:red; font-size:large">
								@Html.ValidationSummary(true, string.Empty, new { id = "validationSummary" })
							</div>
						</form>
					</div>
				</div>
			</div>
			<!-- login end -->
		</div>
		<div class="footer" style="height:130px">
			<p>&copy;@Resources.CopyRightOfCisSystem</p>
			<p id="CopyRightId" style="margin-top:-70px">
				<a href="@Resources.CopyRightOfCisSystemLinkOne" target="_blank" style="color:#999">@Resources.CopyRightOfCisSystemOne &nbsp;&nbsp;</a>
				<a href="@Resources.CopyRightOfCisSystemLinkTwo" target="_blank" style="color:#999"><img src="~/Images/police.png" style="position:relative; top:4px;" />@Resources.CopyRightOfCisSystemTwo</a>
			</p>
		</div>
	</div>
	<div id="mailWindow" class="easyui-window"
		title="@Resources.GetPassword" data-options="closed:true,minimizable:false,iconCls:'icon-save'"
		style="width:600px; display:none;">
		<div class="popupDiv">
			@using (Html.BeginForm(nameof(AccountController.SendPasswordMail),
				nameof(AccountController).GetControllerName(),
				new { ReturnUrl = ViewBag.ReturnUrl },
				FormMethod.Post, new { id = "frmMail" }))
			{
				@Html.AntiForgeryToken()
				<input id="txtMail" name="mail" class="easyui-textbox" style="height:27px; width:350px;" data-options="required:true,validType:['email','length[1,100]'],prompt:'@Resources.MsgEnterMail'" />
				<div class="buttonDiv">
					<input type="button" class="gbtn" onclick="sendMail();" value="@Resources.Submit" />
					<text>&nbsp; &nbsp;</text>
					<input type="button" class="rbtn" onclick="$('#mailWindow').window('close');" value="@Resources.Cancel" />
				</div>
			}
		</div>
	</div>
	<div class="fixedMessageContainer">
		<div class="fixedMessage fixedErrorMessage">
			<h2>Error!</h2>
			<p id="fixedErrorMessageContent"></p>
		</div>
		<div class="fixedMessage fixedSuccessMessage">
			<h2>Success!</h2>
			<p id="fixedSuccessMessageContent"></p>
		</div>
	</div>	
</body>
</html>